﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartApplication.Api.Applient.Command.Kill;
using SmartApplication.Api.Dto;
using SmartApplication.ApiCode;

namespace SmartApplication.Api.Controllers
{
    /// <summary>
    /// 屠宰信息控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class KillController : ControllerBase
    {
        public KillController(IMediator mediator)
        {
            Mediator = mediator;
        }

        public IMediator Mediator { get; }


        /// <summary>
        /// 显示屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<KillDto>>> ListKill([FromQuery]ListKillCommand request)
        {
            return await Mediator.Send(request);
        }

        /// <summary>
        /// 添加屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddKill(AddKillCommand request)
        {
            return await Mediator.Send(request);
        }


        /// <summary>
        /// 修改屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateKill(UpdateKillCommand request)
        {
            return await Mediator.Send(request);
        }


        /// <summary>
        /// 修改屠宰企业信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateBusiness(UpdateBusinessCommand request)
        {
            return await Mediator.Send(request);
        }
    }
}
